﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ECCIT.Data
{
    [Serializable]
    public class WhereClauseBuilder : IToSqlCommand
    {
        public SearchConditionList Conditions { get; set; }

        private WhereClauseBuilder(SearchConditionJoinOperator joinOperator)
        {
            this.Conditions = new SearchConditionList(joinOperator);
        }

        public static WhereClauseBuilder CreateInstance(SearchConditionJoinOperator joinOperator)
        {
            return new WhereClauseBuilder(joinOperator);
        }

        public string ToSqlCommand()
        {
            StringBuilder builder = new StringBuilder(" WHERE ");
            builder.Append(this.Conditions.ToSqlCommand());

            return builder.ToString();
        }
    }
}
